#!/usr/bin/make -f
%:
	dh $@ --with systemd --buildsystem=makefile

override_dh_auto_clean:
	rm -rf build __build_requirements.txt dist salt.spec tiamat.log

override_dh_auto_build:
	/usr/local/bin/tiamat --log-level=debug build -c debian/build.conf
	install -m 755 pkg/deb/salt-api.init debian/salt-api.init
	install -m 755 pkg/deb/salt-master.init debian/salt-master.init
	install -m 755 pkg/deb/salt-minion.init debian/salt-minion.init
	install -m 755 pkg/deb/salt-syndic.init debian/salt-syndic.init

override_dh_auto_install:
	install -d debian/salt-common/opt/saltstack/salt
	cp -at debian/salt-common/opt/saltstack/salt dist/run
	install -D -m 644 pkg/salt.bash debian/salt-common/usr/share/bash-completion/completions/salt-common
	install -D -m 644 pkg/salt-common.logrotate debian/salt-common/etc/logrotate.d/salt-common

override_dh_fixperms:
	dh_fixperms
	chmod 600 debian/salt-cloud/etc/salt/cloud
	chmod 700 debian/salt-cloud/etc/salt/cloud.conf.d
	chmod 700 debian/salt-cloud/etc/salt/cloud.deploy.d
	chmod 700 debian/salt-cloud/etc/salt/cloud.maps.d
	chmod 700 debian/salt-cloud/etc/salt/cloud.profiles.d
	chmod 700 debian/salt-cloud/etc/salt/cloud.providers.d
	chmod 640 debian/salt-master/etc/salt/master
	chmod 640 debian/salt-minion/etc/salt/minion
	chmod 640 debian/salt-minion/etc/salt/proxy
	chmod 640 debian/salt-ssh/etc/salt/roster

override_dh_makeshlibs:
	dh_makeshlibs -Xsalt-common

override_dh_shlibdeps:
	dh_shlibdeps -Xsalt-common
